<extend name="Base/common" />
<block name="style">
	<style>
		.setdiv{padding: 0 0.5rem 0.5rem 0.5rem;background: #FFFFFF;margin-bottom: 1rem;}
		.Setting-label{height: 2rem;display: block;line-height: 2rem;border-top:1px solid #d6d6d6;}
		.band-div{height: 3rem;display: block;line-height: 3rem;}
		.band-name{margin-left: 0.2rem;}
		.band-number{float: right;margin-right: 0.2rem;}
		.Form-group{display: block;padding-top: 0.5rem;}
		.Form-label{padding-bottom: 0.25rem;}
		.number-info{}
		.number-info > input{width: 45%;margin:0 4% 0.5rem 0;display: inline-block;}
		.memberphone{float: left;}
		.membername{float: left;}
		.add-btn{width: 45%;display: block;margin-bottom: 0.5rem;}
	</style>
</block>
<block name="body">
	<input hidden="hidden" value="{$uid}" id="uid"/>
	<div class="setdiv">
		<div class="Setting-label"><span class="band-name">我的乐队</span>
		</div>
		<notempty name="band">
			<foreach name="band" item="v">
				<div class="Setting-label" onclick="editband({$v.id})">
					<span class="band-name">{$v.bandname}</span>
					<span class="band-number">{$v.num}人</span>
				</div>
			</foreach>
			<else/>
			<div class="Setting-label">
				<span class="band-name">您暂无乐队</span>
			</div>
		</notempty>
	</div>
	<div class="setdiv">
		<label class="Form-group">
			<div class="Form-label">乐队名称：</div>
			<input class="form-control mb10" name="bandname" id="bandname"/>
		</label>
		<label class="Form-group" style="padding-top: 0;"><div class="Form-label">乐队成员</div></label>
		<div class="number-info">
			<input class="form-control membername" name="membername" id="membername" placeholder="队员名" />
			<input class="form-control memberphone" name="memberphone" id="memberphone" maxlength="11" placeholder="队员电话" onkeyup="value=value.replace(/[^\d]/g,'') " />
		</div>
		<button class="btn btn-default add-btn" type="button" id="add">+</button>
		<div class="text-align-center mt10"><button class="btn btn-success wid60" type="button" id="save">保存</button></div>
	</div>
</block>
<block name="script">
	<script>
	var uid = $('#uid').val();
	//增加一个乐队
	$('#save').click(function(){
		var bandname = $('#bandname').val(),
			allmembername = $('.membername'),
			allmemberphone = $('.memberphone'),
		    membername =[],
		    memberphone = [];
		for(var i=0;i<allmembername.length;i++){
			membername[i] = $(allmembername[i]).val();
		}
		for(var j=0;j<allmemberphone.length;j++){
			memberphone[j] = $(allmemberphone[j]).val();
		}
		if(!bandname){
			$('#bandname').focus();
		}else{
			if(membername.length!=0){
				$.post("{:U('User/edit_bandmember')}",{uid:uid,bandname:bandname,membername:membername,memberphone:memberphone},function(res){
					console.log(res);
					window.location.reload();
				});
			}else{
				$('#membername').focus();
			}
		}
	});
	// + button监控事件
	$("#add").click(function(){
		var html = '<input class="form-control membername" name="membername" id="membername" placeholder="队员名" />'+
			'<input class="form-control memberphone" name="memberphone" id="memberphone" placeholder="队员电话" maxlength="11"/>';
		$('.number-info').append(html);
	});
	//队员号码只能输入数字

	//进入修改乐队页面
	function editband(id){
		location.href="__ROOT__/User/editband/id/"+id;
	}
	</script>
</block>